package com.base.jdk8;

import com.base.pojo.Apple;

import java.util.Optional;

/**
 * jdk 8为优雅的解决空指针异常，而设计的一个工具类
 *
 * @author: May
 * @date 2020/6/19
 */
public class OptionalTest {
    public static void main(String[] args) {
        Apple apple = new Apple();
        apple = null;
        Optional<Apple> optionalApple = Optional.of(apple);
        String s = optionalApple.toString();
        System.out.println("s = " + s);
    }
}
